<template>
  <div>
  <el-divider style="margin: 0rem;" content-position="left"><h3 style="font-size: 1.15rem;">课程管理</h3></el-divider>
  <my-table listPath="course/page" savePath="course/save" deletePath="course/delete" :table="table" :pageParams="pageParams" :rules="rules" dialogTitle="对话框" :pageSize="[5,10,20,35,50]" :dialogForm="form">
    <template v-slot:dialogSlot>
      <el-form-item label="课程名称" prop="name">
          <el-input v-model="form.name" clearable></el-input>
      </el-form-item>
      <el-form-item label="课时数" prop="classHour">
          <el-input v-model="form.classHour" clearable></el-input>
      </el-form-item>
    </template>
  </my-table>
  </div>
</template>

<script>
  import myTable from '../../components/myTable.vue';
  export default{
    name:'course',
    components:{myTable},
    data() {
      return {

       pageParams:{
            limit:10,
            page:1,
            sort:'id',
            order:'asc',
            search:''
        }
        ,
        form:{
          name:'',
          classHour:''
        },
        table:[
          {
            title:'序号',
            field:'id'
          },
          {
            title:'课程名称',
            field:'name'
          },
          {
            title:'课时数',
            field:'classHour'
          }
        ],
        rules:{
          classHour: [{ required: true, message: '请输入课时数', trigger: 'change' },
                 { pattern:/^\d+(\.\d+)?$/, required: true, message: '课时数只能是数字', trigger: 'change' }],
          name: [{ required: true, message: '请输入课程名称', trigger: 'change' }],
        },
      }
    },
    methods:{
    },
		created() {
			var role =window.sessionStorage.getItem("role")
				if(role!=='ROLE_ADMIN'){
					this.$router.back();
			}
		}
  }
</script>

<style>
</style>
